<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:f="http://java.sun.com/jsf/core"  
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

    <ui:composition template="../index.xhtml">
        <ui:define name="conteudo">
            <h:form id="tituloPagina">
                <h:outputText value="Cadastro de aliquotas"/>
            </h:form>
            <h:form id="formTabela">
                <p:growl/>
                <p:dataTable id="listContasPagar" var="forn" value="#{aliquotaControler.listAliquotas}" widgetVar="carsTableAtivos" style="width: 50%;"
                             rowKey="#{forn.id}" selectionMode="single"  emptyMessage="Nenhum registro foi encontrado!" paginator="true" rows="10" rowsPerPageTemplate="5,10,15,#{aliquotaControler.listAliquotas.size()}">
                    <f:facet name="header">  
                        <p:outputPanel>  
                            <h:outputText value="Digite para pesquisar " />
                            <p:inputText id="globalFilter" onkeyup="carsTableAtivos.filter()" style="width:150px" /> 
                            <p:commandButton value="Novo" accesskey="N" onclick="dlgAliquota.show()" action="#{aliquotaControler.inicializaObj()}" update=":formAdd"/>
                        </p:outputPanel>  
                    </f:facet>  
                    <p:column headerText="Ações" footerText="Ações" filterMatchMode="Ações" style="width: 60px;">  
                        <p:commandButton action="#{aliquotaControler.setAliquota(forn)}" onclick="dlgAliquota.show();" update=":formAdd"
                                         image="ui-icon ui-icon-pencil" title="alterar" />
                        <p:commandButton image="ui-icon ui-icon-close" title="excluir" 
                                         actionListener="#{aliquotaControler.setAliquota(forn)}" onclick="confirmationExcluirgrupo.show();"/>
                    </p:column>
                    <p:column filterBy="${forn.descricao}" headerText="Descrição" footerText="Descrição" sortBy="${forn.descricao}">    
                        <h:outputText value="${forn.descricao}" />  
                    </p:column>  
                    <p:column filterBy="${forn.descricao}" headerText="Observação" footerText="Observação" sortBy="${forn.descricao}">    
                        <h:outputText value="${forn.obs}" />  
                    </p:column>  
                </p:dataTable>
            </h:form>
            <p:dialog id="dialogFunc" header="Nova aliquota de ICMS" widgetVar="dlgAliquota" modal="true" resizable="false" appendToBody="true">  
                <h:form id="formAdd">
                    <p:messages/>
                    <h:inputHidden value="#{aliquotaControler.aliquota.id}"/>
                    <h:panelGrid columns="2">
                        <h:outputText value="Código"/>
                        <p:inputText value="#{aliquotaControler.aliquota.id}" disabled="true" size="5"/>

                        <h:outputText value="Descrição"/>
                        <p:inputText value="#{aliquotaControler.aliquota.descricao}" required="true" requiredMessage="Informe a aliquota!!">
                            <p:focus/>
                        </p:inputText>

                        <h:outputText value="Observação:"/>
                        <p:inputText value="#{aliquotaControler.aliquota.obs}" size="50" maxlength="30"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <p:commandButton value="Salvar" accesskey="S" action="#{aliquotaControler.salvar()}" update="formAdd :formTabela" onclick="statusDialog.show();" onsuccess="statusDialog.hide();"/>
                        <p:commandButton value="Novo" accesskey="N" update=":formAdd" action="#{aliquotaControler.inicializaObj()}" process="@this"/>
                        <p:commandButton value="Cancelar" accesskey="C" onclick="dlgAliquota.hide()" process="@this"/>
                    </h:panelGrid>
                </h:form>
                <!-- confirmações  de exclusão-->
                <h:form>
                    <p:confirmDialog id="confirmDialog" message="Confirma excluir este grupo?" appendToBody="true"
                                     header="Atenção!!!" severity="alert" widgetVar="confirmationExcluirgrupo" >  
                        <p:commandButton id="confirm" value="Sim" oncomplete="confirmationExcluirgrupo.hide()"  
                                         actionListener="#{aliquotaControler.excluir()}" update=":formTabela"/>  
                        <p:commandButton id="decline" value="Cancelar" onclick="confirmationExcluirgrupo.hide()" type="button" />   
                    </p:confirmDialog>
                </h:form>
            </p:dialog>
        </ui:define>
    </ui:composition>
</html>